//
//  SocialPongMainScene.h
//  SocialPong
//
//  Created by stacie on 8/21/10.
//  Copyright __MyCompanyName__ 2010. All rights reserved.
//


// When you import this file, you import all the cocos2d classes
#import "cocos2d.h"
#import "Box2D.h"
#import "GLES-Render.h"
#import "MyContactListener.h"
#import <AudioToolbox/AudioToolbox.h>


// SocialPong Layer
@interface SocialPong : CCLayer
{
    b2World *_world;
    b2Body *_groundBody;
    b2Fixture *_bottomFixture;
    b2Fixture *_topFixture;
    b2Fixture *_leftWallFixture;
    b2Fixture *_rightWallFixture;

    b2Fixture *_ballFixture;

    b2Body *_leftPaddleBody;
    b2Fixture *_leftPaddleFixture;

    b2Body *_rightPaddleBody;
    b2Fixture *_rightPaddleFixture;

    CCLabel *_scoreLabelLeft;
    CCLabel *_scoreLabelRight;
        
    CCLabel *_speedLabelLeft;
    CCLabel *_speedLabelRight;

    //b2Body *_paddleBody;
    //b2Fixture *_paddleFixture;

    b2MouseJoint *_mouseJoint;
    MyContactListener *_contactListener;
    
    int _scoreLeft;
    int _scoreRight;
    int _scoreMax;
    int _lastHitObj;
    int _speedLeft;
    int _speedRight;
    int _speedMin;
    int _speedMax;
    
    SystemSoundID _pingFx;
    SystemSoundID _buzzFx;

    b2Vec2 _ballStartingPos;
    CCSprite *_ball;
        
	//GLESDebugDraw *m_debugDraw;
	// server grab
	NSMutableData *receivedData;
	NSArray *officialVotes;
}

@property (nonatomic, retain) NSMutableData *receivedData;
@property (nonatomic, retain) NSArray *officialVotes;



// returns a Scene that contains the HelloWorld as the only child
+(id) scene;

// adds the paddle(s):
//-(void) addBottomPaddle:(CGSize)winSize withFilename:(NSString *)fname;
-(void) addPaddle:(CGSize)winSize withId:(int)paddleId;
-(void) playPing;
-(void) addScores;
-(void) checkPing:(int)nextObj withMessage:(NSString *)logMsg;
-(void) checkScoreUpdate: (int)nextObj withMessage:(NSString *)logMsg;
-(void) resetBall:(float)velocityFactor;
-(void) setPaddleSpeed:(int)paddleId;
-(void)getServerVotes;
-(void)parseResult;

// adds a new sprite at a given coordinate
//-(void) addNewSpriteWithCoords:(CGPoint)p;

@end
